<?php
/*
Plugin Name: Desire Secret
Plugin URI: http://wordpress.org/extend/plugins/monWidget/
Description:  Widget qui affiche les désirs les plus secrets
Version: 1.0
Author: Maxime Laperle -Siavashnia
Author URI: http://strangework.com

*/

/*  Copyright 2012  Maxime Laperle Siavashnia  (email : brad@webdevstudios.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


add_action( 'widgets_init', 'ds_register_widgets' );

 //register our widget
function ds_register_widgets() {
    register_widget( 'DesireSecret_widget' );
}




class DesireSecret_widget extends WP_Widget
{
		function DesireSecret_widget(){
			$widget_opts = array('classname' => 'DesireSecret_widget', 'description' => __('Démontrer son plus grand désir agrave; l\'internaute ','ds-plugin') );  
			$this->WP_Widget('desire_widget_bio', __('Desire Secret','ds-plugin'), $widget_opts);
		
		}

		function form($instance){
			$defaults = array('name' => __('My name and desire','ds-plugin'), 'ds' => '' ); 
			$instance = wp_parse_args( (array) $instance, $defaults );
			$name = strip_tags($instance['name']);
			$ds = strip_tags($instance['ds']);
			
			?>
					<p><?php _e('Name','ds-plugin') ?>: <input class="widefat" name="<?php echo $this->get_field_name('name'); ?>"  type="text" value="<?php echo esc_attr($name); ?>" /></p>
					<p><?php _e('Plus grand desir secret','ds-plugin') ?>: <textarea class="widefat" name="<?php echo $this->get_field_name('ds'); ?>" / > <?php echo esc_attr($ds); ?></textarea></p>
			<?php
		}
		
		function update($new_instance, $old_instance) {
			$instance = $old_instance;
			$instance['name'] = strip_tags($new_instance['name']);
			$instance['ds'] = strip_tags($new_instance['ds']);
 
			return $instance;
		}

		function widget($args, $instance) {
				extract($args);
		 
				echo $before_widget;
				$name = apply_filters('widget_name', $instance['name'] );
				$ds = empty($instance['ds']) ? '&nbsp;' : apply_filters('widget_ds', $instance['ds']); 
		 
				if ( !empty( $name ) ) { echo $before_name . $name . $after_name; };
				echo '<p>' .__('Plus grand desir secret','ds-plugin') .': ' . $ds . '</p>';
				echo $after_widget;
		}
















} // fin classe du widget 


?>